package com.medical.data.controller;

import com.medical.data.domain.HospitalInformation;
import com.medical.data.service.HospitalInformationService;
import com.medical.data.utils.Result;
import com.medical.data.vo.HospitalVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(description = "医院管理")
@RequestMapping("/front/hospital")
@RestController
@Slf4j
public class HospitalController {


    @Autowired
    private HospitalInformationService hospitalService;

    @ApiOperation("获取所有的医院")
    @PostMapping("/getHospital")
    public Result getHospital(){
        log.info("/front/hospital/getHospital参数列表======>{}","无");
        List<HospitalInformation> hospitalInformations = hospitalService.getHospital();
        return Result.ok().data("hospitals",hospitalInformations);
    }

    @ApiOperation("新增医院")
    @PostMapping("/insertHospital")
    public Result insertHospital(@Validated @RequestBody HospitalVo hospitalVo){
        log.info("/front/hospital/insertHospital参数列表======>{}",hospitalVo);
        hospitalService.insertHospital(hospitalVo);
        return Result.ok();
    }


}
